package com.eshop.modules.system.service.mapper;

import org.apache.ibatis.annotations.Select;
import java.util.Set;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.eshop.modules.system.domain.Dept;
import com.eshop.common.mapper.CoreMapper;

@Repository
public interface DeptMapper extends CoreMapper<Dept>
{
    @Select({ "select m.* from dept m LEFT JOIN roles_depts t on m.id= t.dept_id LEFT JOIN role r on r.id = t.role_id where r.id = ${roleId}" })
    Set<Dept> findDeptByRoleId(@Param("roleId") final Long roleId);
    
    @Select({ "select * from dept m LEFT JOIN roles_depts t on m.id= t.dept_id LEFT JOIN role r on r.id = t.role_id where r.id = #{roleId}" })
    Set<Dept> findDeptByRoleIds(@Param("roleIds") final Set<Long> roleId);
}
